#include "level3.h"

Level3::Level3(QWidget *parent)
    : LevelScene(QPixmap(RESOURCE_DIR + "/Rose_Future_Map.png"),QImage(RESOURCE_DIR + "/Rose_Future_Mask.png"), parent)
{
    buildingImage = new GameBackground(QPixmap(RESOURCE_DIR + "/Rose_Future_Buildings.png"),mainScene);
    buildingImage->setZValue(1);

    // Add the tools
    quarantineTool = addTool(QString("Quarantien (Place road block)"),RESOURCE_DIR + "/buttons/Kit_Quarantine.png");
    sterilizationTool = addTool(QString("Sterilize building"),RESOURCE_DIR + "/buttons/Dean_Sterilize.png");
    vacceneTool = addTool(QString("Vaccenate people in building"),RESOURCE_DIR + "/buttons/Kit_Pills.png");
    antiviralTool = addTool(QString("Prescribe building antiviral drugs"),RESOURCE_DIR + "/buttons/Kit_Pills.png");
    gammaglobulinTool = addTool(QString("Prescribe building Gammaglobulians"),RESOURCE_DIR + "/buttons/Kit_Pills.png");
    geneTherapyTool = addTool(QString("Give people in a building gene therapy"),RESOURCE_DIR + "/buttons/Kit_Pills.png");

    // Add one story houses
    QPointF house1Info[49][2] = {{QPointF(220,895),QPointF(23,91)},
                                 {QPointF(220+52,895),QPointF(31,91)},
                                 {QPointF(220,946),QPointF(24,98)},
                                 {QPointF(220+52,946),QPointF(29,98)},

                                 {QPointF(344,895),QPointF(35,91)},
                                 {QPointF(344+52,895),QPointF(43,91)},
                                 {QPointF(344,946),QPointF(37,42)},
                                 {QPointF(344+52,946),QPointF(86,98)},

                                 {QPointF(14,1020),QPointF(5,104)},
                                 {QPointF(14,1020+51),QPointF(4,111)},

                                 {QPointF(96,1020),QPointF(10,104)},
                                 {QPointF(96+52,1020),QPointF(18,104)},
                                 {QPointF(96,1020+51),QPointF(12,111)},
                                 {QPointF(96+52,1020+51),QPointF(17,111)},

                                 {QPointF(220,1020),QPointF(23,104)},
                                 {QPointF(220+52,1020),QPointF(31,104)},
                                 {QPointF(220,1020+51),QPointF(25,111)},
                                 {QPointF(220+52,1020+51),QPointF(30,111)},

                                 {QPointF(344,1020),QPointF(35,104)},
                                 {QPointF(344+52,1020),QPointF(43,104)},
                                 {QPointF(344,1020+51),QPointF(37,111)},
                                 {QPointF(344+52,1020+51),QPointF(42,111)},

                                 {QPointF(14,1144),QPointF(5,116)},
                                 {QPointF(14,1144+51),QPointF(4,112)},

                                 {QPointF(96,1144),QPointF(10,116)},
                                 {QPointF(96+52,1144),QPointF(18,116)},
                                 {QPointF(96,1144+51),QPointF(12,112)},
                                 {QPointF(96+52,1144+51),QPointF(17,112)},

                                 {QPointF(220,1144),QPointF(23,116)},
                                 {QPointF(220+52,1144),QPointF(31,116)},
                                 {QPointF(220,1144+51),QPointF(25,112)},
                                 {QPointF(220+52,1144+51),QPointF(30,112)},

                                 {QPointF(344,1144),QPointF(35,116)},
                                 {QPointF(344+52,1144),QPointF(43,116)},
                                 {QPointF(344,1144+51),QPointF(37,112)},
                                 {QPointF(344+52,1144+51),QPointF(42,112)},

                                 {QPointF(1922,346),QPointF(193,37)},
                                 {QPointF(1922,346+51),QPointF(194,43)},
                                 {QPointF(1922,478),QPointF(193,50)},
                                 {QPointF(1922,478+60),QPointF(194,58)},
                                 {QPointF(1922,628),QPointF(193,65)},
                                 {QPointF(1922,628+60),QPointF(194,73)},
                                 {QPointF(1922,778),QPointF(193,80)},
                                 {QPointF(1922,778+60),QPointF(195,88)},
                                 {QPointF(1922,928),QPointF(193,95)},
                                 {QPointF(1922,928+60),QPointF(195,103)},
                                 {QPointF(1922,1078),QPointF(193,110)},
                                 {QPointF(1922,1078+60),QPointF(194,118)},
                               };

    for (unsigned int index = 0; index < (sizeof(house1Info)/(sizeof(*house1Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house1Info[index][1].toPoint()),QPointF(house1Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_1home" + buildingColor + ".png"));
    }

    // Add two story houses
    QPointF house2Info[42][2] = {{QPointF(1076,245),QPointF(110,31)},
                                 {QPointF(1076+65,245),QPointF(116,31)},
                                 {QPointF(1373,371),QPointF(139,43)},
                                 {QPointF(1373+50,371),QPointF(144,43)},
                                 {QPointF(1498,371),QPointF(152,43)},
                                 {QPointF(1498+50,371),QPointF(157,43)},
                                 {QPointF(1749,371),QPointF(177,43)},
                                 {QPointF(1749+55,371),QPointF(182,43)},
                                 {QPointF(1749,520),QPointF(177,58)},
                                 {QPointF(1749+55,520),QPointF(182,58)},
                                 {QPointF(1623,520),QPointF(165,58)},
                                 {QPointF(1623+50,520),QPointF(170,58)},
                                 {QPointF(1749,822),QPointF(177,88)},
                                 {QPointF(1749+55,822),QPointF(183,88)},
                                 {QPointF(1749,972),QPointF(177,103)},
                                 {QPointF(1749+55,972),QPointF(183,103)},
                                 {QPointF(1749,1122),QPointF(177,118)},
                                 {QPointF(1749+55,1122),QPointF(183,118)},
                                 {QPointF(1621,1122),QPointF(164,118)},
                                 {QPointF(1621+51,1122),QPointF(170,118)},
                                 {QPointF(1496,1122),QPointF(152,118)},
                                 {QPointF(1496+51,1122),QPointF(157,118)},

                                 {QPointF(47,70),QPointF(7,13)},
                                 {QPointF(47+50,70),QPointF(12,13)},
                                 {QPointF(172,70),QPointF(20,13)},
                                 {QPointF(172+50,70),QPointF(24,13)},
                                 {QPointF(297,196),QPointF(32,25)},
                                 {QPointF(297+50,196),QPointF(37,25)},
                                 {QPointF(297,322),QPointF(32,38)},
                                 {QPointF(297+50,322),QPointF(37,38)},
                                 {QPointF(172,322),QPointF(19,38)},
                                 {QPointF(172+50,322),QPointF(24,38)},

                                 {QPointF(1172,45),QPointF(119,10)},
                                 {QPointF(1172+50,45),QPointF(124,10)},
                                 {QPointF(1297,45),QPointF(132,10)},
                                 {QPointF(1297+50,45),QPointF(137,10)},
                                 {QPointF(1422,45),QPointF(144,10)},
                                 {QPointF(1422+50,45),QPointF(149,10)},
                                 {QPointF(1547,45),QPointF(157,10)},
                                 {QPointF(1547+50,45),QPointF(162,10)},
                                 {QPointF(1672,45),QPointF(169,10)},
                                 {QPointF(1672+50,45),QPointF(174,10)},
                                };

    for (unsigned int index = 0; index < (sizeof(house2Info)/(sizeof(*house2Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house2Info[index][1].toPoint()),QPointF(house2Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_2home" + buildingColor + ".png"));
    }

    // Add three story house
    QPointF house3Info[6][2] = {{QPointF(1224,223),QPointF(129,29)},
                                {QPointF(299,49),QPointF(37,11)},
                                {QPointF(424,174),QPointF(49,24)},
                                {QPointF(424,299),QPointF(49,36)},
                                {QPointF(1049,0),QPointF(112,6)},
                                {QPointF(924,-25),QPointF(99,4)},
                                };

    for (unsigned int index = 0; index < (sizeof(house3Info)/(sizeof(*house3Info[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 4);
        addBuilding(QPoint(house3Info[index][1].toPoint()),QPointF(house3Info[index][0]),QPixmap(RESOURCE_DIR + "/buildings/Rose_3home" + buildingColor + "-small.png"));
    }

    // Add office buildings
    QPointF officeInfo[33][2] = {{QPointF(767,325),QPointF(80,43)},
                                 {QPointF(767+65,325),QPointF(87,43)},
                                 {QPointF(917,325),QPointF(95,43)},
                                 {QPointF(917+65,325),QPointF(102,43)},
                                 {QPointF(1066,325),QPointF(110,43)},
                                 {QPointF(1066+65,325),QPointF(117,43)},
                                 {QPointF(1217,325),QPointF(125,43)},
                                 {QPointF(1217+65,325),QPointF(132,43)},

                                 {QPointF(767,470),QPointF(80,58)},
                                 {QPointF(767+65,470),QPointF(86,58)},
                                 {QPointF(917,470),QPointF(95,58)},
                                 {QPointF(917+65,470),QPointF(101,58)},
                                 {QPointF(767,620),QPointF(80,73)},
                                 {QPointF(767+65,620),QPointF(86,73)},
                                 {QPointF(917,620),QPointF(95,73)},
                                 {QPointF(917+65,620),QPointF(101,73)},
                                 {QPointF(917,770),QPointF(95,88)},
                                 {QPointF(917+65,770),QPointF(101,88)},
                                 {QPointF(1066,470),QPointF(110,58)},
                                 {QPointF(1066+65,470),QPointF(116,58)},
                                 {QPointF(1217,470),QPointF(125,58)},
                                 {QPointF(1217+65,470),QPointF(131,58)},
                                 {QPointF(1380,470),QPointF(141,58)},
                                 {QPointF(1402,620),QPointF(143,73)},
                                 {QPointF(1367,770),QPointF(140,88)},
                                 {QPointF(1380,920),QPointF(141,103)},
                                 {QPointF(1380,1070),QPointF(141,118)},
                                 {QPointF(1216,1070),QPointF(125,118)},
                                 {QPointF(1216+65,1070),QPointF(131,118)},
                                 {QPointF(767,920),QPointF(80,103)},
                                 {QPointF(767+65,920),QPointF(87,103)},
                                 {QPointF(767,1070),QPointF(80,118)},
                                 {QPointF(767+65,1070),QPointF(87,118)},
                                };

    for (unsigned int index = 0; index < (sizeof(officeInfo)/(sizeof(*officeInfo[0])*2)); index++)
    {
        char buildingColor = '1' + (rand() % 3);
        addBuilding(QPoint(officeInfo[index][1].toPoint()),QPointF(officeInfo[index][0]),QPixmap(RESOURCE_DIR + "/buildings/1Skyscraper" + buildingColor + ".png"));
    }

    // Add other buildings
    addBuilding(QPoint(88,85),QPointF(775,785),QPixmap(RESOURCE_DIR + "/buildings/2PostOffice.png"));
    addBuilding(QPoint(93,102),QPointF(920,935),QPixmap(RESOURCE_DIR + "/buildings/1FireStation.png"));

    QString convertString;

    for (int count = 0; count<100; count ++)
    {
        convertString.setNum((rand()%12) + 1);
        addPerson(QPixmap(RESOURCE_DIR + "/people/Dean_Person" + convertString + ".png"),buildings.at(rand() % buildings.length()));
    }

    addPerson(QPixmap(RESOURCE_DIR + "/Kit_Person.png"),buildings.at(2));
    people.last()->virus = new Virus(0,10,0,0,0,0);

}
